#include <iostream>
#include <vector>
#include <Windows.h>
#include "BarleyBreak.h"

using namespace std;


int main() {

	vector <vector <int>> matrix( fieldSize, vector<int>( fieldSize, 0 ) ); 

	/*for ( int i = 0; i < fieldSize; ++i ) {
		for ( int j = 0; j < fieldSize; ++j ) {
			matrix[i][j] = i*fieldSize + j + 1;
		}
	}
	matrix[3][3] = 12;
	matrix[2][3] = 11;
	matrix[2][2] = 10;
	matrix[2][1] = 6;
	matrix[1][1] = 0; */

	printf("Print field please:\n");

	for ( int i = 0; i < fieldSize; ++i ) {
		for ( int j = 0; j < fieldSize; ++j ) {
			scanf("%d", &matrix[i][j]);
		}
	}

	BarleyBreakCase myCase(matrix);
	SolveBarleyBreak solve(myCase);
	
	vector< pair<BarleyBreakCase, char> > solution;

	if ( solve.isSolutionExists() ) {
		solution = solve.GetSolution();
		printf("\nSolution:\n");
	}
	else {
		printf("\nNo solution\n");
	}

	for ( int k = solution.size() - 1; k >= 0 ; --k ) {
		if ( solution[k].second != '$' )
			printf("%c ", solution[k].second);
	}

	system("pause");
	return 0;
}

